package apIExercise.String;

import java.util.Locale;
import java.util.Random;
import java.util.Scanner;

public class charAt {
    public static void main(String[] args) {
        String str="thinking in java";
        char c=str.charAt(9);//获取str中下标9的字符
        System.out.println(c);//i


        Scanner scan=new Scanner(System.in);
        Random radn=new Random();
        System.out.println("请输入验证码的长度：");
        int len=scan.nextInt();
        //StringBuilder code=new StringBuilder(" ");
       // String a1=code.toString();
        String code="";
        String s="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789";
        for(int i=0;i<len;i++){
            code+=s.charAt(radn.nextInt(s.length()));
           // code=code.append(s.charAt(radn.nextInt(s.length())));
         //   a1=a1.toUpperCase(Locale.ROOT);

        }
       String code1=code.toUpperCase(Locale.ROOT);
        System.out.println(code);
        System.out.println("请输入验证码：");
        String a=scan.next();
        a=a.toUpperCase(Locale.ROOT);
        if(a.equals(code1)){
            System.out.println("输入成功");
        }


    }

}
